//
//  MenuCollectionViewCell.m
//  Cooking
//
//  Created by dllo on 15/8/24.
//  Copyright (c) 2015年 ZP.Y. All rights reserved.
//

#import "MenuCollectionViewCell.h"
#import "AppMacro.h"
#import "UIImageView+WebCache.h"
#import "FoodModel.h"
@interface MenuCollectionViewCell ()

@property (retain, nonatomic) UIImageView *foodView;
@property (retain, nonatomic) UILabel     *foodName;

@end

@implementation MenuCollectionViewCell

- (void)dealloc {
    [_foodView release];
    [_foodName release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView {
    self.foodView = [[UIImageView alloc] init];
    //        _foodView.backgroundColor = [UIColor grayColor];
    _foodView.layer.cornerRadius = (WIDTH / 3 - 40) / 2;
    _foodView.layer.masksToBounds = YES;
    [self.contentView addSubview:_foodView];
    [_foodView release];
    
    self.foodName = [[UILabel alloc] init];
//            _foodName.backgroundColor = [UIColor grayColor];
    _foodName.font = [UIFont systemFontOfSize:14.5];
    _foodName.textColor = [UIColor colorWithRed:235 / 255.0 green:79 / 255.0 blue:56 / 255.0 alpha:1];
    _foodName.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:_foodName];
    [_foodName release];
}
- (void)layoutSubviews {
    [super layoutSubviews];
    _foodView.frame = CGRectMake(0, 0, WIDTH / 3 - 40, WIDTH / 3 - 40);
      _foodView.center = self.contentView.center;
    _foodName.frame = CGRectMake(0, _foodView.frame.origin.y + _foodView.frame.size.height + 3, WIDTH / 3, 20);
}

- (void)sendValueWithModel:(FoodModel *)foodModel {
    _foodName.text = foodModel.name;
    _foodView.contentMode = UIViewContentModeCenter;
    [_foodView sd_setImageWithURL:[NSURL URLWithString:foodModel.imageFilename]];
}

@end
